package com.ruoyi.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.ServletUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import javax.annotation.Resource;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.FinCurrency;
import com.ruoyi.project.service.IFinCurrencyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 币别Controller
 * 
 * @author abel
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/project/FinCurrency")
public class FinCurrencyController extends BaseController
{
    @Resource
    private IFinCurrencyService finCurrencyService;

    /**
     * 查询币别列表
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:list')")
    @GetMapping("/list")
    public TableDataInfo list(FinCurrency finCurrency)
    {
        startPage();
        finCurrency.setPackageId(ServletUtils.getPackageId());
        List<FinCurrency> list = finCurrencyService.selectFinCurrencyList(finCurrency);
        return getDataTable(list);
    }

    /**
     * 导出币别列表
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:export')")
    @Log(title = "币别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinCurrency finCurrency)
    {
        List<FinCurrency> list = finCurrencyService.selectFinCurrencyList(finCurrency);
        ExcelUtil<FinCurrency> util = new ExcelUtil<FinCurrency>(FinCurrency.class);
        util.exportExcel(response, list, "币别数据");
    }

    /**
     * 获取币别详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(finCurrencyService.selectFinCurrencyById(id));
    }

    /**
     * 新增币别
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:add')")
    @Log(title = "币别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinCurrency finCurrency)
    {
        return toAjax(finCurrencyService.insertFinCurrency(finCurrency));
    }

    /**
     * 修改币别
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:edit')")
    @Log(title = "币别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinCurrency finCurrency)
    {
        return toAjax(finCurrencyService.updateFinCurrency(finCurrency));
    }

    /**
     * 删除币别
     */
    @PreAuthorize("@ss.hasPermi('project:FinCurrency:remove')")
    @Log(title = "币别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(finCurrencyService.deleteFinCurrencyByIds(ids));
    }
}
